package com.yangqi.io;

import java.io.*;

public class Copy {
    public static void main(String[] args) {
        String path1 = "D:\\home\\cache\\copy.jpg";
        String path2 = "D:\\home\\cache\\copy_bak.jpg";
        BufferedOutputStream bos = null;
        BufferedInputStream bis = null;
        try {
             bos = new BufferedOutputStream(new FileOutputStream(path2));
             bis = new BufferedInputStream(new FileInputStream(path1));
             byte[] buff = new byte[1024];
             int len = 0;
             while((len = bis.read(buff)) != -1){
                 bos.write(buff,0,len);
             }
            System.out.println("复制成功");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
